package org.spring.blog.service;

import org.spring.blog.response.ResponseResult;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public interface IImageService {

    String app_download_path = "/portal/app";
    String db_image_original_all = "all";
    String db_image_original_loop = "loop";
    String db_image_original_user_avatar = "avatar";
    String db_image_original_friend_link = "friend_link";
    String db_image_original_article = "article";
    String db_image_original_article_cover = "cover";

    /**
     * 返回二维码的方法
     *
     * @param _code     二维码对应的id
     * @param _request  请求体
     * @param _response 响应体
     */
    void getQrCodeImage(String _code, HttpServletResponse _response, HttpServletRequest _request);

    interface constant {
        String[] support_image_type = {"image/png", "image/gif", "image/jpg", "image/jpeg"};
        int list_default_page_num = 1;
        int list_min_page_size = 5;
    }

    /**
     * 上传图片
     *
     * @param _file     文件路径
     * @param _original 图片来源
     * @return 自定义返回对象
     */
    ResponseResult uploadImage(MultipartFile _file, String _original) throws IOException;

    /**
     * 查找图片
     *
     * @param _url      图片id
     * @param _response 响应体
     */
    void query(String _url, HttpServletResponse _response) throws IOException;

    /**
     * 获取图片列表
     *
     * @param _page     页码
     * @param _size     页面大小
     * @param _original 图片来源
     * @return 自定义返回对象
     */
    ResponseResult list(int _page, int _size, String _original);

    /**
     * 删除图片
     *
     * @param _id 图片id
     * @return 自定义返回对象
     */
    ResponseResult delete(String _id);
}